<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="../js/vue.global.js"></script>
</head>
<body>
    <div id="app">
        <p>{{count}}</p>
        <p>
            <button @click="count++">count++</button>
        </p>
        <hr>
        <p>
            {{zhang.name}}----{{zhang.age}}---{{zhang.info.height}}
           
        </p>
        <p>
            <button @click="zhang.age++">age++</button>
            <button @click="zhang.info.height++">height++</button>
        </p>
    </div>
</body>
<script>
    let {createApp} = Vue;
    let {ref,reactive,readonly} = Vue;

    // readonly
    // 接受一个对象 (不论是响应式还是普通的) 或是一个 ref，返回一个原值的只读代理。

    var app = createApp({
        
        setup(props) {

            let count = ref(100);  /// ref对象
            // console.log(count);

            let addCount = ()=>{
                count.value ++;
            }

            // zhang ->代理对象
            let zhang = reactive({// 目标对象
                name:"张三",
                age:18,
                info:{
                    height:173,
                    weight:65
                }
            });  // new Proxy(data,{get,set})
            // console.log(zhang);

            // 将传入的ref对象 proxy对象变为只读
            count = readonly(count);
            console.log(count);

            zhang = readonly(zhang);
            console.log(zhang);


            return {

                // 键名: 传递出去的数据名 方法名  计算属性
                count:count,
                addCount,
                zhang,
            }
            
        },
        mounted() {
            // console.log("this",this);
        },
    })

    app.mount("#app");








</script>
</html>